<template>
    <div class="body" id="wekupButton">
    <div
      class="header"
      @click="hear"
    >
    </div>
    <img
      @click="hear"
      class="hanner"
      src="../../assets/img/fen/back.png"
      alt=""
    >
    <img
      @click="hear"
      class="hanner2"
      src="../../assets/img/fen/back2.png"
      alt=""
    >
    <div
      class="btn"
      @click="to"
    >查看更多</div>
    <!-- 置顶 -->
    <div
      class="totop"
      id="totop"
      @click="backTop"
      v-show="btnFlag"
    >
      <!-- <i class="iconfont icon-zhiding"></i> -->
    </div>
  </div>
</template>

<script>
import bridge from '../../js/js1'
import { index, Coupondev } from '@/api/index'
import { share } from '../../js/public'
import { getSystem, openApp, getUrlQuery, parseKeyValue } from '../../js/js'
export default {
  // 组件名称
  name: '',
  // 局部注册的组件
  components: {},
  // 组件参数 接收来自父组件的数据
  props: {},
  // 组件状态值
  data () {
    return {
      scrollTop: 0,
      system: getSystem(),
      btnFlag: false,
      share: true,
      show: false,
    }
  },
  // 计算属性
  computed: {},
  // 侦听器
  watch: {},
  // 生命周期钩子   注：没用到的钩子请自行删除
  /**
  * 组件实例创建完成，属性已绑定，但DOM还未生成，$ el属性还不存在
  */
  created () {
  },
  /**
  * el 被新创建的 vm.el 替换，并挂载到实例上去之后调用该钩子。
  * 如果 root 实例挂载了一个文档内元素，当 mounted 被调用时 vm.el 也在文档内。
  */
  destroyed () {
    window.removeEventListener('scroll', this.scrollToTop);
  },
  mounted () {
    window.addEventListener('scroll', this.scrollToTop)
    share({
      title: '媛福达2周年庆攻略',
      desc: '三重福利大放送，2000余件商品直击底价，爆品预售低至6折起，点击查看详情',
      imgUrl: 'https://download.yuanfuda933.com/h5/images/hot.png',
      shareUrl: 'https://download.yuanfuda933.com/h5/other2.html#/hot',
      share: this.share,
    })
  },
  // 组件方法
  methods: {
    // 点击图片回到顶部方法，加计时器是为了过渡顺滑
    backTop () {
      const that = this
      let timer = setInterval(() => {
        let ispeed = Math.floor(-that.scrollTop / 5)
        document.documentElement.scrollTop = document.body.scrollTop = that.scrollTop + ispeed
        if (that.scrollTop === 0) {
          clearInterval(timer)
        }
      }, 16)
    },
    // 为了计算距离顶部的高度，当高度大于60显示回顶部图标，小于60则隐藏
    scrollToTop () {
      const that = this
      let scrollTop = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop
      that.scrollTop = scrollTop
      // console.log(that.scrollTop);
      if (that.scrollTop > 800) {
        that.btnFlag = true
      } else {
        that.btnFlag = false
      }
    },
    to () {
      window.location.href = 'yfd://yfdmall:8080/homePage'
    },
    hear () {
      this.$toast('敬请期待周年庆典!')
    },
    href (uri, blank = true) {
      const a = document.createElement('a')
      a.style.display = 'none'
      a.href = uri
      if (blank) a.setAttribute('target', '_blank')
      document.body.appendChild(a)
      a.click()
      setTimeout(t => {
        document.body.removeChild(a)
      }, 0)
    },
  }
}
</script>

<style scoped lang="less">
.body {
  overflow: hidden;
  min-width: 320px;
  max-width: 750px;
  width: 10rem;
  // height: 91.28rem;
  background: #fddb49;
  margin: 0 auto;
  line-height: 1.5;
  font-family: Arial, Helvetica;
  .rigth {
    position: fixed;
    top: 0;
    z-index: 9999;
    width: 10rem;
    height: 30rem;
    background-color: #1e1e1e;
    opacity: 0.8;
  }
  .rigth img {
    width: 8rem;
    height: 4.4rem;
    float: right;
  }
  .totop {
    position: fixed;
    width: 1.2rem; /* 40/16 */
    height: 1.2rem;
    border-radius: 1.25rem /* 20/16 */;
    opacity: 0.8;
    background: url("../../assets/ding.png") no-repeat;
    background-size: contain;
    box-shadow: 0 1px 5px 0 #e0e0e0;
    right: 0.125rem; /* 18/16 */
    bottom: 3rem; /* 64/16 */
    z-index: 1100;
    -webkit-transition: opacity 0.5s;
    transition: opacity 0.5s;
  }
  .header {
    width: 10rem;
    height: 17.333333rem;
    background: url("../../assets/img/fen/header.png") no-repeat;
    background-size: contain;
  }
  .hanner {
    width: 10rem;
    height: 93.866667rem;
  }
  .hanner2 {
    width: 10rem;
    height: 34.773333rem;
  }
  .btn {
    margin: 0.4rem auto;
    border-radius: 0.6rem;
    width: 4.586667rem;
    height: 1.013333rem;
    text-align: center;
    line-height: 1.013333rem;
    font-size: 0.586667rem;
    color: #ffffff;
    background: #806efe;
  }
}
</style>
